package com.mikelouis.test.scala.proginscala.chapter14

import org.scalatest.FunSuite

/**
 * Use ScalaTest to write test suite 2
 *
 * Created by yuazhu on 1/16/2015.
 */
class Element2ScalaTestSuite2 extends FunSuite {
  test("elem result should have passed width") {
    val ele = Element2.elem('x', 2, 3)
    // assert(ele.width == 2)
    assertResult(2) {
      ele.width
    }
  }

  test("The method should throw an Exception") {
    val s = "hi"
    intercept[IndexOutOfBoundsException] {
      s.charAt(-1)
    }
  }

  /**
   * test if expected exception is thrown in intercept function
   */
  test("the method throw an unexpected Exception") {
    intercept[IllegalArgumentException] {
      Element2.elem('x', -2, 3)
    }
  }

}
